package day09;

import java.util.Objects;

public class StringTools05 {
    public static void main(String[] args) {
        Preson p1 = new Preson("老王", 50);
        Preson p2 = new Preson("老王", 50);
        System.out.println(p1==p2);//false
        System.out.println(p1.equals(p2));//false,重写后true
        System.out.println(p1.name==p2.name);//true
        System.out.println(p1.age==p2.age);//true
        System.out.println(p1.hashCode());
        System.out.println(p2.hashCode());
    }
}
class Preson{
    String name;
    int age;

    public Preson(String name, int age) {
        this.name = name;
        this.age = age;
    }

//    @Override
//    public boolean equals(Object o) {
//        if (this == o) return true;
//        if (o == null || getClass() != o.getClass()) return false;
//        Preson preson = (Preson) o;
//        return age == preson.age && Objects.equals(name, preson.name);
//    }
//
//    @Override
//    public int hashCode() {
//        return Objects.hash(name, age);
//    }
}